local dangping = fk.CreateSkill {
  name = "lingling__dangping",
}

Fk:loadTranslationTable{
  ["lingling__dangping"] = "荡平",
  [":lingling__dangping"] = "出牌阶段限一次，你可以弃置一张牌，对一名距离为1的其他角色造成3点雷电伤害。此伤害变至等于1前，"..
  "将受到伤害的角色可以弃置一张牌，令此伤害-1并转移给另一名角色。",

  ["#lingling__dangping"] = "荡平：弃一张牌，对一名距离1的角色造成3点雷电伤害！",
  ["#lingling__dangping-discard"] = "荡平：你即将受到%arg点雷电伤害！是否弃一张牌伤害-1并转移伤害？",
}

dangping:addEffect("active", {
  anim_type = "offensive",
  prompt = "#lingling__dangping",
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(dangping.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and not player:prohibitDiscard(to_select)
  end,
  target_filter = function(self, player, to_select, selected, cards)
    return #selected == 0 and player:distanceTo(to_select) == 1
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:throwCard(effect.cards, dangping.name, player, player)
    local n = 3
    while n > 1 and not target.dead do
      local to, card = room:askToChooseCardsAndPlayers(target, {
        min_card_num = 1,
        max_card_num = 1,
        min_num = 1,
        max_num = 1,
        targets = room:getOtherPlayers(target, false),
        skill_name = dangping.name,
        prompt = "#lingling__dangping-discard:::"..n,
        cancelable = true,
        will_throw = true,
      })
      if #to > 0 then
        room:throwCard(card, dangping.name, target, target)
        target = to[1]
        n = n - 1
      else
        room:damage{
          from = player,
          to = target,
          damage = n,
          skillName = dangping.name,
          damageType = fk.ThunderDamage,
        }
        return
      end
    end
    if not target.dead then
      room:damage{
        from = player,
        to = target,
        damage = n,
        skillName = dangping.name,
        damageType = fk.ThunderDamage,
      }
    end
  end,
})

return dangping